package leetcode.problems;

import org.junit.Test;

/**
 * Created by gmwang on 2018/7/25
 * 翻转string
 */
public class _0806ReverseString {
    /**
     *
     * Write a function that takes a string as input and returns the string reversed.
     *
     * Example 1:
     *
     * Input: "hello"
     * Output: "olleh"
     * Example 2:
     *
     * Input: "A man, a plan, a canal: Panama"
     * Output: "amanaP :lanac a ,nalp a ,nam A"
    /**
     *
     * @param s
     * @return
     */
    public String reverseString(String s) {
        StringBuilder sb = new StringBuilder();
        char[] chars = s.toCharArray();
        for (int i = chars.length - 1; i>=0; i--) {
            sb.append(chars[i]);
        }
        return sb.toString();
    }
    @Test
    public void test() {
//        String ints = "hello";
        String ints = "A man, a plan, a canal: Panama";
        String res = reverseString(ints);
        System.out.println(res);
    }
}
